<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('功能设置')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-docset-edit" th:object="${sysDocset}">
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">注册设置：</label>
                <div class="col-sm-8">
                    <input type="checkbox" id="email" th:checked="${sysDocset.email == 1 ? true : false}">使用邮箱注册
                </div>
                <div class="col-sm-8">
                    <input type="checkbox" id="phone" th:checked="${sysDocset.phone == 1 ? true : false}">使用手机号注册
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">邀请码：</label>
                <div class="col-sm-8">
                    <input type="checkbox" id="invite" th:checked="${sysDocset.invite == 1 ? true : false}">
                </div>

            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">默认用户组：</label>
                <div class="col-sm-8">
                    <select id="groupid" class="form-control">

                        <option th:each="item :${sysGroupList}" th:value="${item.groupid}" th:selected="${item.groupid}==${sysDocset.groupid}" th:text="${item.groupname}"></option>
                    </select>
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">VIP用户组：</label>
                <div class="col-sm-8">
                    <select id="vgroupid" class="form-control">
                        <option value="0">请选择</option>
                        <option th:each="item :${sysVgroupList}" th:value="${item.vgroupid}" th:selected="${item.vgroupid}==${sysDocset.vgroupid}" th:text="${item.vgroupname}"></option>
                    </select>
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">VIP用户组时间：</label>
                <div class="col-sm-8">
                    <input name="vgroupdays" th:field="*{vgroupdays}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">密码最小长度：</label>
                <div class="col-sm-8">
                    <input name="pwdLength" th:field="*{pwdLength}" class="form-control" type="text">
                </div>
            </div>
        </div>

        <div class="col-xs-18">
            <div class="form-group">
                <label class="col-sm-3 control-label">密码复杂度：</label>
                <div class="col-sm-8">
                    <input type="checkbox" id="pwdNum" th:checked="${sysDocset.pwdNum == 1 ? true : false}">密码必须包含数字<br>
                    <input type="checkbox" id="pwdLower" th:checked="${sysDocset.pwdLower == 1 ? true : false}">密码必须包含小写字母<br>
                    <input type="checkbox" id="pwdUpper" th:checked="${sysDocset.pwdUpper == 1 ? true : false}">密码必须包含大写字母
                </div>

            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">验证邮箱主题：</label>
            <div class="col-sm-8">
                <textarea id="inviteTitle" name="inviteTitle" class="form-control">[[*{inviteTitle}]]</textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">验证邮箱内容：</label>
            <div class="col-sm-8">
                <textarea id="inviteBody" name="inviteBody" class="form-control">[[*{inviteBody}]]</textarea>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-offset-5 col-sm-10">
                <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            </div>
        </div>


    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<script th:inline="javascript">
    var prefix = ctx + "system/regset";
    $("#form-docset-edit").validate({
        focusCleanup: true
    });
    function submitHandler() {
        if ($.validate.form()) {
            var data = $('#form-docset-edit').serializeArray();
            var email = $("input[id='email']").is(':checked') == true ? 1 : 0;
            var phone = $("input[id='phone']").is(':checked') == true ? 1 : 0;
            var pwdNum = $("input[id='pwdNum']").is(':checked') == true ? 1 : 0;
            var pwdLower = $("input[id='pwdLower']").is(':checked') == true ? 1 : 0;
            var pwdUpper = $("input[id='pwdUpper']").is(':checked') == true ? 1 : 0;
            var invite = $("input[id='invite']").is(':checked') == true ? 1 : 0;
            var groupid = $.form.selectSelects("groupid");
            var vgroupid = $.form.selectSelects("vgroupid");
            data.push({"name": "groupid", "value": groupid});
            data.push({"name": "vgroupid", "value": vgroupid});
            data.push({"name": "email", "value": email});
            data.push({"name": "phone", "value": phone});
            data.push({"name": "pwdNum", "value": pwdNum});
            data.push({"name": "pwdLower", "value": pwdLower});
            data.push({"name": "pwdUpper", "value": pwdUpper});
            data.push({"name": "invite", "value": invite});
            $.operate.save(prefix + "/edit", data,function(result) {
                layer.msg(result.msg, {
                    icon: $.modal.icon(0),
                    time: 500,
                    shade: [0.1, '#8F8F8F']
                });
            });
        }
    }
</script>
</body>
</html>